package com.wman.lib.activity;

import android.view.View;

import com.wman.lib.R;
import com.wman.lib.delegate.ListFrameDelegate;
import com.wman.sheep.mvp.base.backactivity.BaseBackActivity;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;

/**
 * Name     youcai
 * Anthor   wman
 * Time     2019/8/19 10:53
 * Describe 装载列表类Fragment，一般都是列表
 */
public class ListActivity extends BaseBackActivity<ListFrameDelegate> {
    public static final String EXTRA_ACTION = "action";

    private FragmentTransaction mTrans;
    private Fragment fragment;

    @Override
    public void onResume() {
        super.onResume();
    }

    @Override
    public void onPause() {
        super.onPause();
    }

    @Override
    protected boolean isShowTitleBar() {
        String action = getIntent().getStringExtra(EXTRA_ACTION);
        if (action == null) {
            finishAnimationActivity();
            return false;
        }
        if (action.equals("shop_list")) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    protected void bindEventListener() {

    }

    @Override
    protected Class<ListFrameDelegate> getDelegateClass() {
        return ListFrameDelegate.class;
    }

    @Override
    protected void initData() {
        String action = getIntent().getStringExtra(EXTRA_ACTION);
        if (action != null) {
            mTrans = getSupportFragmentManager().beginTransaction();
            switch (action) {
                case "shop_list"://商品列表
//                    fragment = HousePosterSelectFragment.getInstance();
                    break;
                default:
                    finishAnimationActivity();
            }
            mTrans.add(R.id.content_frame, fragment);
            mTrans.commit();
        } else {
            finishAnimationActivity();
        }
    }

    @Override
    public void onNoDoubleClick(View v) {
        switch (v.getId()) {
            default:
                finishAnimationActivity();
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }
}
